package cn.cdeden.knowledge.service;

import cn.cdeden.common.core.utils.page.TableDataInfo;
import cn.cdeden.knowledge.domain.AnalysisData;
import cn.cdeden.knowledge.domain.EnterpriseFilesTree;
import cn.cdeden.knowledge.domain.TreeDownloadFiles;
import cn.cdeden.knowledge.domain.dto.*;
import cn.cdeden.knowledge.enums.TeamFilesTreeRenameParam;
import cn.cdeden.knowledge.vo.EnterpriseFilesTreeVO;
import cn.cdeden.resource.api.domain.RemoteFilesDownload;
import cn.cdeden.resource.api.domain.RemoteFilesUpload;
import cn.cdeden.system.api.domain.enums.EnterprisePermTypeEnum;
import cn.cdeden.system.api.model.LoginUser;
import com.baomidou.mybatisplus.extension.service.IService;
import io.undertow.util.BadRequestException;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import org.springframework.data.domain.Pageable;
import org.springframework.transaction.annotation.Transactional;

import java.util.Collection;
import java.util.List;

public interface EnterpriseFilesTreeService extends IService<EnterpriseFilesTree>{

    EnterpriseFilesTreeDto queryList(EnterpriseFilesTreeQueryParam query, Boolean isCheckPerm);

    /**
     * 查询数据分页
     *
     * @param query    条件
     * @param pageable 分页参数
     */
    TableDataInfo<EnterpriseFilesTreeDto> queryAll(EnterpriseFilesTreeQueryParam query, Pageable pageable);


    EnterpriseFilesTreeDto queryAll(EnterpriseFilesTreeQueryParam query, Boolean isCheckPerm);

    EnterpriseFilesTreeDto insertData(EnterpriseFilesTreeDto resources, Boolean isException);

    void insertRemark(Long id, String remark);

    EnterpriseFilesTree createFile(@NotNull RemoteFilesUpload remoteFilesUpload, @NotBlank String parentId, @NotBlank String realName, String abstractName, String author, String fileEncode, @NotBlank String userId, @NotBlank String userName,String fileDatasetId,LoginUser user);

    @Transactional(rollbackFor = Exception.class)
    EnterpriseFilesTree insert(EnterpriseFilesTreeDto resources, Boolean isException);

    EnterpriseFilesTree nameRechecking(String realName, String parentId, String suffix);

    List<TreeNodeDto> queryEnterpriseFiles(String treeNodeId);
    //置顶
    void topMark(FilesTreeTop top) throws BadRequestException;

    //修改文件所有上级大小
    void setParentNodeSize(String parentId, Long size, int addAndMinus);

    List<String> getChildAllById(String id);

    void rechristen(TeamFilesTreeRenameParam dto) throws BadRequestException;

    boolean rename(EnterpriseFilesTreeDto enterpriseFilesTreeDto);


    TableDataInfo<FilesTree> searchFilesTree(SearchFilesInfoDto infoDto, Pageable pageable);

    List<FilesTree> selectFilesTree(Collection<String> ids);

    List<FilesTree> selectFilesTree(Collection<String> ids, String userId);

    List<FilesTree> selectFilesTree(Collection<String> ids, String userId, boolean b);


    HeadKnowLab queryKnowLab(EnterpriseFilesTreeQueryParam query, Boolean isCheckPerm);


    List<KnowLab> queryKnowLab();

    Boolean newBuiltKnowLab(@NotBlank String classify, @NotBlank String name, String remark, @NotBlank String imageUrl, String kowLabId, String templateId, String location, Integer sort);

    void editKnowLab(@NotNull Long id, @NotBlank String realName, @NotBlank String classify, String remarks, @NotBlank String imageUrl,String location,Integer sort);

    void deleteKnowLab(Long id);

    List<EnterpriseFilesTree> nameRecheckingVerifyData(String parentId);

    @Transactional(rollbackFor = Exception.class)
    EnterpriseFilesTreeDto createFolderFilePath(String parentId, String filePath);

    List<RemoteFilesDownload> folderSonFiles(List<String> ids, String userId, Boolean b, EnterprisePermTypeEnum enterprisePermTypeEnum);

    List<AnalysisData> analysisKnowLab();

    TableDataInfo<EnterpriseFilesTreeDto> commonAnalysisKnowLab(Pageable pageable);

    List<DataItem> getAllParentId(String id);

    int selectByIdTreePageInfo(String userId,List<Long> deptIds,List<Long> roles,List<Long> jobIds, String treeId, String parentId, Integer size, List<String> sort, Boolean isPerm);

    //获得文件树
    EnterpriseFilesTreeDto getFolder(Long templateId);

    void updateDify(List<Long> ids);

    EnterpriseFilesTreeVO getPortalFile(Long fileId);

    void createFolder(TeamToEnterpriseDto teamToEnterprise, String userId, String abstractName, String username, String parentId, int count);

    void createFolder(PersonalToEnterpriseDto teamToEnterprise, String userId, String abstractName, String username, String parentId, int count) throws BadRequestException;

    void toDify(List<Long> ids);

    void createFileToEs(Long dataId);
}
